package com.lxw.manage.course.service.impl;

import com.lxw.framework.domain.course.CourseMarket;
import com.lxw.framework.model.response.CommonCode;
import com.lxw.framework.model.response.ResponseResult;
import com.lxw.manage.course.dao.CourseMarketRepository;
import com.lxw.manage.course.service.ICourseMarketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
public class CourseMarketServiceImpl implements ICourseMarketService {
    @Autowired
    CourseMarketRepository courseMarketRepository;


    @Override
    public CourseMarket findCourseMarketById(String courseId) {
        // 课程营销表的主键和课程信息的主键保持一致
        Optional<CourseMarket> byId = courseMarketRepository.findById(courseId);
        if(byId.isPresent()){
            return byId.get();
        }
        return null;
    }

    @Override
    public ResponseResult update(CourseMarket courseMarket) {
        courseMarketRepository.save(courseMarket);
        return new ResponseResult(CommonCode.SUCCESS);
    }
}
